-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Adding Clause Interleaving to method definitions #14019
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6dd2a68
to
e765617
Compare
f0926c1
to
1a85e94
Compare
3a5026c
to
93ff8f1
Compare
8bd5b36
to
1f8a1bd
Compare
9422ead
to
541ec60
Compare
bishabosha
reviewed
Feb 18, 2022
docs/docs/reference/other-new-features/generalized-method-syntax.md
Outdated
Show resolved
Hide resolved
ccc7657
to
a2f2b9a
Compare
I'm not sure if you thought about the type system when a method application is split to blocks. class Box[T](x: T)
def huge[T1, T2](
t1: T1, t2 : T2, r : Int
)[T3, T4](t3: T3, r2: Int, t4: T4)[T5](t5 : T5*): Box[(T1, T2, T3, T4, T5)] = ???
val h1p1 = huge((1, 2), (3, 4), 5)
val h1p2 = h1p1((6, 7), 8, (9, 10))
val h1p3 = h1p2(11, 12)
val h1pTest: Box[((Int, Int), (Int, Int), (Int, Int), (Int, Int), Int)] = h1p3 |
a31a6c7
to
0742ffb
Compare
The new syntax allows arbitrary interleaving of type and term clauses for methods TypelessClause{|s} is added for class constructors since they still don't allow interleaving of type parameters Also unifies the affected grammar variable names so that <x>s means "one or more <x>" Implicit clauses are moved apart from term clause to make it more obvious they can only be the last clause
Interweaved methods still fail at use-cite, see next commit
A check is removed that forbids interleaved methods at use-site This however breaks named type parameters, some tests are thus removed methType implicitly assumed there could only be one leading term parameter clause, this has been changed
This commit is only here for the sake of legibility, it breaks tests If you want to come back in the history, go to either the previous commit or the next
This adds back the TypeApply case that was present in Applications.scala. With it is an improved error message that shows a potential fix.
0742ffb
to
0b67f48
Compare
Not fixup'ed with another commit to keep a trace of the original version of these methods.
0b67f48
to
65091c3
Compare
julienrf
added a commit
to scala/improvement-proposals
that referenced
this pull request
Feb 3, 2023
hamzaremmal
added a commit
that referenced
this pull request
Jul 4, 2024
odersky
pushed a commit
to odersky/improvement-proposals
that referenced
this pull request
Jul 18, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This aims to add the ability to declare functions with many clauses of type parameters, instead of at most one, and to allow those clauses to be interleaved with term clauses:
All user-facing details can be found in the Scala 3 new features doc, and in the SIP proposal
The implementation details are described below in the commit messages
The community's opinion of the feature can be found on the scala contributors forum
(note however that the description there is somewhat outdated)
Dependencies
This feature has been accepted by the SIP committee for implementation, it can therefore become part of the language as an experimental feature at any time.
The feature will be available with
import scala.language.experimental.clauseInterleaving
How to make non-experimental
git revert
the commits named "Make clause interleaving experimental" and "Add import to tests":Future Work
(Started as a semester project with supervision from @smarter, now part of my missions as an intern at the scala center)